package com.lyp.qczp.service;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import com.lyp.qczp.dao.Rolesdao;
import com.lyp.qczp.entity.Roles;

@Service
public class RolesServiceImp implements RolesService {
	
	@Autowired
	private Rolesdao rolesdao;

	@Override
	public int save(Roles roles) {
		Roles save = rolesdao.save(roles);
		if (save!=null) {
			return 1;
		}
		return 0;
	}

	@Override
	public int deleteById(Integer eId) {
		// TODO Auto-generated method stub
		rolesdao.deleteById(eId);
		return 1;
	}

	@Override
	public Map<String, Object> findAll(PageRequest pageable) {
		Page<Roles> findAll = rolesdao.findAll(pageable);
		
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("rows", findAll.getContent());
		map.put("total", findAll.getTotalElements());
		return map;
	}
	
}
